//
//  ViewController.m
//  GKBHouse
//
//  Created by  on 12-6-19.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"
#import "AppDelegate.h"
#import "Global1.h"
#import "TimeAlarmSetViewController.h"

@implementation ViewController
@synthesize mainController;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
//    NSString *name[6] = {@"ad1.jpg", @"ad2.jpg", @"ad3.jpg", @"ad4.jpg", @"ad5.jpg", @"ad6.jpg"};
    
//    NSArray *nameArray = @[@"ad1.jpg", @"ad2.jpg", @"ad3.jpg", @"ad4.jpg", @"ad5.jpg", @"ad6.jpg"];
//    
//    if (IOS7_OR_LATER) {
//        nameArray = @[@"ad1_4c.jpg", @"ad2_4c.jpg", @"ad3_4c.jpg", @"ad4_4c.jpg", @"ad5_4c.jpg", @"ad6_4c.jpg"];
//    }
//    
//    uint ran = arc4random();
//    int index = ran%6;
//    NSLog(@"%d, %d", ran, index);
//    
//    NSString *name = [nameArray objectAtIndex:index];
    
    NSString *name = @"ad.jpg";
    
    if (DEVICE_IS_4INCHES) {
        name = @"ad_4c.jpg";
    }
    
    UIImage *image = [UIImage imageNamed:name];
    UIImageView *imageView = [[UIImageView alloc]init];
    [imageView setFrame:CGRectMake(0, 0, DEVICE_HEIGHT, DEVICE_WIDTH)];
    [imageView setImage:image];
    [self.view addSubview:imageView];
    [imageView release];
    
    
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
 //   
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    NSTimer *openMainTimer;
    openMainTimer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(openMain)userInfo:nil repeats:NO];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
//{
//    // Return YES for supported orientations
//    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
//}
#pragma mark - mainmenu
- (void)openMain
{
    LoginController1 *login = [[LoginController1 alloc]initWithNibName:@"LoginController1" bundle:nil];
    [self presentModalViewController:login animated:NO];
    [login release];
    return;
    GKBMainController *controller = [[GKBMainController alloc]initWithNibName:@"GKBMainController" bundle:nil];
    self.mainController = controller;
    [controller release];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;

    [self presentModalViewController:self.mainController animated:NO];
    NSLog(@"openmain");
}
@end
